# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=soxr
pkgver=0.1.3
pkgrel=2
pkgdesc="High quality, one-dimensional sample-rate conversion library"
url="https://sourceforge.net/projects/soxr"
arch="all"
license="LGPL-2.1-or-later"
depends_dev="cmake"
makedepends="$depends_dev"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev"
source="$pkgname-$pkgver.tar.xz::https://sourceforge.net/projects/soxr/files/soxr-$pkgver-Source.tar.xz/download"
builddir="$srcdir/$pkgname-$pkgver-Source"

build() {
	mkdir -p "$builddir"/static "$builddir"/shared

	# We can't build the static and shared libs in one go, so build them one by one...
	cd "$builddir"/static
	cmake \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr \
		-DBUILD_SHARED_LIBS=False \
		-DBUILD_TESTS=ON \
		-DCMAKE_BUILD_TYPE=None \
		..
	make

	cd "$builddir"/shared
	cmake \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_TESTS=ON \
		-DCMAKE_BUILD_TYPE=None \
		..
	make
}

check() {
	cd "$builddir"/static
	make test
	cd "$builddir"/shared
	make test
}

package() {
	cd "$builddir"/static
	make DESTDIR="$pkgdir" install
	cd "$builddir"/shared
	make DESTDIR="$pkgdir" install
}

doc() {
	mkdir -p "$subpkgdir/usr"
	mv "$pkgdir/usr/share" "$subpkgdir/usr/share"
}

sha512sums="f4883ed298d5650399283238aac3dbe78d605b988246bea51fa343d4a8ce5ce97c6e143f6c3f50a3ff81795d9c19e7a07217c586d4020f6ced102aceac46aaa8  soxr-0.1.3.tar.xz"
